#include "bitelog.h"

namespace bitelog {
    std::shared_ptr<spdlog::logger> g_logger;

    void bitelog_init(const log_settings& settings) {
        // 1. 判断日志器类型
        // 2. 判断日志输出目标
        // 3. 创建日志器
        if(settings.async == true) {
            if(settings.path == "stdout") {
                g_logger = spdlog::stdout_color_mt<spdlog::async_factory>("stdout_logger");
            } else {
                g_logger = spdlog::basic_logger_mt<spdlog::async_factory>("file_logger", settings.path);
            }
        } else {
            if(settings.path == "stdout") {
                g_logger = spdlog::stdout_color_mt("stdout_logger");
            } else {
                g_logger = spdlog::basic_logger_mt("file_logger", settings.path);
            }
        }
        //4. 设置日志等级
        g_logger->set_level(spdlog::level::level_enum(settings.level));
        //5. 设置日志格斯
        g_logger->set_pattern(settings.format);
    }

} // end namespace bitelog